package com.pcbly.web.components.utils.template.action;

import com.pcbly.web.bean.user.*;
import com.pcbly.web.components.utils.template.AbstractModel;
import com.pcbly.web.components.utils.template.ModelPrint;

public class ModelCommonAction extends ModelPrint {
	public void execute(Class<?> clz) {
		if(print){
			ModelActionXml(clz);
			ModelActionApp(clz);
		}else{
			ModelAction(clz);
			ModelActionXml(clz);
			ModelActionApp(clz);
		}

	}

	private void ModelAction(Class<?> clz) {
		AbstractModel model = new ModelAction(clz);
		model.setTableName(tableName);
		model.execute();
	}

	private void ModelActionXml(Class<?> clz) {
		AbstractModel model = new ModelActionXml(clz);
		model.setTableName(tableName);
		model.setPrint(print);
		model.execute();
	}

	private void ModelActionApp(Class<?> clz) {
		AbstractModel model = new ModelActionApp(clz);
		model.setTableName(tableName);
		model.setPrint(print);
		model.execute();
	}

	private String tableName;

	public String getTableName() {
		return tableName;
	}

	public void setTableName(String tableName) {
		this.tableName = tableName;
	}

	public static void main(String[] args) {
		ModelCommonAction model = new ModelCommonAction();
		model.setTableName("sys_user_school");
		model.setPrint(false);
		model.execute(UserSchoolBean.class);
	}
}
